<script setup lang="ts">
import { reactive, ref } from "vue";
import { currentGET } from "@/api";
import CountUp from "@/components/count-up";
const duration = ref(2);
const state = reactive({
  totalPeople: 0,
  usePeople: 0,
  totalOrder: 0,
  platformRevenue: 0,
  energyConsumption: 0,
  other:{}
});

const getData = () => {
  currentGET("leftTop").then((res) => {
    console.log(res);
    if (res.success) {
      state.totalPeople = res.data.totalPeople;
      state.usePeople = res.data.usePeople;
      state.totalOrder = res.data.totalOrder;
      state.platformRevenue = res.data.platformRevenue;
	  state.energyConsumption = res.data.energyConsumption;
	  state.other = res.data.other;
    }
  });
};
getData();
</script>

<template>
	<div class="user_Overview_nums allnum" style="font-size: 20px;margin-left: 60px;">
		当前在线设备/设备总数<div style="text-align:center;color: aqua;font-size: 16px;margin-left: 100px;border: 5px solid sandybrown;border-radius: 50%;width: 55px;height: 55px;position: absolute;line-height: 40px;display: inline-block;">{{state.other.percent}}</div><br>
		{{state.other.onlineNum}}/{{state.other.totalNum}}
	</div>
	<div class="user_Overview_nums online" style="font-size: 20px;margin-left: 60px;">
		当前使用端口/充电端口总数<div style="text-align:center;color: aqua;font-size: 16px;margin-left: 60px;border: 5px solid sandybrown;border-radius: 50%;width: 55px;height: 55px;position: absolute;line-height: 40px;display: inline-block;">{{state.other.hatchPercent}}</div><br>
		{{state.other.useHatch}}/{{state.other.totalHatch}}
	</div>
	<div class="user_Overview_nums offline" style="font-size: 20px;margin-left: 60px;">
		用户数量<br>
		{{state.totalPeople}}
	</div>
	<div class="user_Overview_nums laramnum" style="font-size: 20px;margin-left: 60px;">
	  总充电次数<br>
	  {{state.totalOrder}}
	</div>
	<div class="user_Overview_nums online" style="font-size: 20px;margin-left: 60px;">
	  总消耗电能数<br>
	  {{state.energyConsumption}}
	</div>
</template>

<style scoped lang="scss">
.left-top {
  width: 100%;
  height: 100%;
}

.user_Overview {
  li {
    flex: 1;

    p {
      text-align: center;
      height: 16px;
      font-size: 16px;
    }

    .user_Overview_nums {
      width: 100px;
      height: 100px;
      text-align: center;
      line-height: 100px;
      font-size: 22px;
      margin: 50px auto 30px;
      background-size: cover;
      background-position: center center;
      position: relative;

      &::before {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
      }

      &.bgdonghua::before {
        animation: rotating 14s linear infinite;
      }
    }

    .allnum {
      &::before {
        background-image: url("@/assets/img/left_top_lan.png");
      }
    }

    .online {
      &::before {
        background-image: url("@/assets/img/left_top_lv.png");
      }
    }

    .offline {
      &::before {
        background-image: url("@/assets/img/left_top_huang.png");
      }
    }

    .laramnum {
      &::before {
        background-image: url("@/assets/img/left_top_hong.png");
      }
    }
  }
}
</style>
